package com.freesun.shop.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freesun.shop.entity.ProdFavorite;
import com.freesun.shop.mapper.ProdFavoriteMapper;

import com.freesun.shop.service.ProdFavoriteService;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>
 * 商品收藏表 服务实现类
 * </p>
 *
 * @author zf
 * @since 2019-11-13
 */
@Service
public class ProdFavoriteServiceImpl extends ServiceImpl<ProdFavoriteMapper, ProdFavorite> implements ProdFavoriteService {
    private static Logger logger = LoggerFactory.getLogger(ProdFavoriteServiceImpl.class);
    @Override
    public Boolean calUserIsComllection(Long prodId, String userId) {
        logger.info("本次查询商品为:{},用户ID为:{}",prodId,userId);
        Integer count = this.baseMapper.selectCount(new LambdaQueryWrapper<ProdFavorite>()
                .eq(ProdFavorite::getProdId, prodId)
                .eq(ProdFavorite::getUserId, userId));
        return count!=null&&count>0;
    }
}
